function getAge(birthday=new Date()) {
  var csrq = birthday;
  var age = "";
  var d = new Date();
  var year = d.getFullYear();
  var month = d.getMonth() + 1;
  var day = d.getDate();
  if (month < 10) {
    month = "0" + month;
  }
  if (day < 10) {
    day = "0" + day;
  }
  var now = year + "-" + month + "-" + day;
  if (
    now.substring(0, 4) >= csrq.substring(0, 4) &&
    now.substring(5, 7) >= csrq.substring(5, 7) &&
    now.substring(8, 10) >= csrq.substring(8, 10)
  ) {
    age = year - parseInt(csrq.substring(0, 4));
  } else {
    age = year - parseInt(csrq.substring(0, 4)) - 1;
  }
  return age;
}

export default getAge;
